package ${de.packageName}.controller;
/*
*此文件生成Mybatis的controller文件
*/
import ${de.packageName}.entity.${de.entityName};
import ${de.packageName}.log.ActLog;
import ${de.packageName}.service.${de.entityName}Service;
import ${de.packageName}.util.HdUtil;
import ${de.packageName}.entity.vo.PageParam;
import ${de.packageName}.entity.vo.ResultObject;
import ${de.packageName}.entity.vo.EasyUIResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;

/**
 * ${de.tableComment}Controller
 *	
 * 
 * @Date ${.now?date}
 */
@Controller
@RequestMapping(value = "${r'${adminPath}'}/${de.packageNameSuffix?replace(".","/")}/${entityNam}")
public class ${entityNam}Controller {
    @Resource
    private ${de.entityName}Service ${de.entityNameAlias}Service;
    
    Logger logger = LoggerFactory.getLogger(${entityNam}Controller.class);

  
  
  
      /**
     * 跳转用
     *
     * @param model
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/toPage")
    public String toPage(Model model) {
        return "modules/${de.packageNameSuffix?replace(".","/")}/${entityNam}?date="+System.currentTimeMillis();
    }
    
    
    /**
     * 查询${de.tableComment}返回easyUI
     *
     * @param request
     * @param pageParam
     * @return
     * @author 
     * @date ${.now?date}
     */
    @ResponseBody
    @RequestMapping("get${entityNam}EasyUIList")
    public EasyUIResult get${entityNam}List(HttpServletRequest request, PageParam pageParam) {
    	HashMap params = HdUtil.getRequestParams(request);
      EasyUIResult easyUIResult=null;
      try{
          easyUIResult=${de.entityNameAlias}Service.get${entityNam}EasyUIList(params, pageParam);
      }catch(Exception e){
          e.printStackTrace();
          logger.error(HdUtil.getStackTrace(e));
      }
      return easyUIResult;
    }


/**
     * 查询${de.tableComment}全部数据
     *
     * @param request
     * @param pageParam
     * @return
     * @author
     * @date ${.now?date}
     */
    @ResponseBody
    @RequestMapping("getAll${entityNam}List")
    public List<${entityNam}> getAll${entityNam}List(HttpServletRequest request, PageParam pageParam) {
        HashMap params = HdUtil.getRequestParams(request);
        List<${entityNam}> result=null;
        try{
            result=feeTypeService.getAll${entityNam}List(params);
        }catch(Exception e){
            e.printStackTrace();
            logger.error(HdUtil.getStackTrace(e));
        }
        return result;
    }

 /**
     * 查询${de.tableComment}
     *
     * @param request
     * @param pageParam
     * @return
     * @author 
     * @date ${.now?date}
     */
    @ResponseBody
    @RequestMapping("get${entityNam}List")
    public List get${entityNam}List(HttpServletRequest request, PageParam pageParam) {
    	HashMap params = HdUtil.getRequestParams(request);
      List result=null;
      try{
          result=${de.entityNameAlias}Service.get${entityNam}List(params, pageParam);
      }catch(Exception e){
          e.printStackTrace();
          logger.error(HdUtil.getStackTrace(e));
      }
      return result;
    }

    /**
     * 保存${de.tableComment}
     *
     * @param 
     * @return
     * @author 
     * @date ${.now?date}
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "save${entityNam}")
    public ResultObject save${entityNam}(HttpServletRequest request) {
    	ResultObject resultObject=null;
    	HashMap params = HdUtil.getRequestParams(request);
    	try{
            resultObject=${de.entityNameAlias}Service.save${entityNam}(params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(HdUtil.getStackTrace(e));
            resultObject=new ResultObject(1,"保存出错，请联系管理员");
        }
        return resultObject;
    }

    /**
     * 删除${de.tableComment}
     *
     * @param 
     * @return
     * @author
     * @date ${.now?date}
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "delete${entityNam}")
    public ResultObject delete${de.entityName}(HttpServletRequest request) {
    	ResultObject resultObject=null;
    	HashMap params = HdUtil.getRequestParams(request);
        try{
            resultObject=${de.entityNameAlias}Service.delete${entityNam}(params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(HdUtil.getStackTrace(e));
            resultObject=new ResultObject(1,"删除出错，请联系管理员");
        }
        return resultObject;
    }
    /**
    * 单独删除${de.tableComment}
    *
    * @param
    * @return
    * @author
    * @date ${.now?date}
    */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "singelDeleteCodPort")
    public ResultObject singelDeleteCodPort(HttpServletRequest request) {
        ResultObject resultObject=null;
        HashMap params = HdUtil.getRequestParams(request);
        try{
            resultObject=${de.entityNameAlias}Service.singelDelete${entityNam}(params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(HdUtil.getStackTrace(e));
            resultObject=new ResultObject(1,"删除出错，请联系管理员");
        }
        return resultObject;
    }


}
